Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Archive Migration] batch 2 of removing es_archives/empty_kibana #138208

Merged
merged 12 commits into from
Aug 23, 2022

Conversation

LeeDr
Copy link

@LeeDr LeeDr commented Aug 5, 2022

Summary

Part of Meta issue: #102552

This PR removes the use of es_archives/empty_kibana and replaced it with calls to kibanaServer.savedObjects.cleanStandardList. Similar to this PR #138189

WARNING: I should note that there is a difference between
esArchiver.load('x-pack/test/functional/es_archives/empty_kibana'); (which I think deletes the entire .kibana index) and
kibanaServer.savedObjects.cleanStandardList(); (which can only delete savedObjects of types supported by the Saved Object API in the DEFAULT SPACE). There might be some types of saved objects which are not deleted. The full set we delete are here https://github.com/elastic/kibana/blob/main/packages/kbn-test/src/kbn_client/kbn_client_saved_objects.ts#L225 And saved objects in other spaces wouldn't be deleted. I mostly used find/replace to generate this PR and didn't review all the tests in detail. But the tests passed! The fact that our tests are broken up into so many separate configs probably helps with the isolation of tests.
I find that generally tests that created a space also already had an after method that deletes the space (and everything in it).

@LeeDr LeeDr added test_xpack_functional release_note:skip Skip the PR/issue when compiling release notes backport:prev-minor Backport to (9.0) the previous minor version (i.e. one version back from main) Feature:Functional Testing labels Aug 5, 2022
@LeeDr
Copy link
Author

LeeDr commented Aug 5, 2022

There seem to be some tests here which are creating spaces and not cleaning them up at the end, which causes a failure when the next test tries to create a space which already exists. I don't know these tests but it seems like these should be matching pairs of setupSpacesAndUsers and tearDown? This could be a case where es_archives/empty_kibana would have wiped out everything in the .kibana index including spaces but cleanStandardList doesn't do that.

main/kibana - (remove_empty_kibana_2) > grep -r setupSpacesAndUsers x-pack/test/alerting_api_integration/security_and_spaces/group2/* | wc -l
      13
main/kibana - (remove_empty_kibana_2) > 
main/kibana - (remove_empty_kibana_2) > grep -r tearDown x-pack/test/alerting_api_integration/security_and_spaces/group2/* | wc -l           
       7

@LeeDr
Copy link
Author

LeeDr commented Aug 15, 2022

@elasticmachine merge upstream

@kibanamachine
Copy link
Contributor

merge conflict between base and head

@LeeDr LeeDr marked this pull request as ready for review August 15, 2022 17:29
@LeeDr LeeDr requested review from a team as code owners August 15, 2022 17:29
@LeeDr LeeDr requested a review from a team August 15, 2022 17:29
@LeeDr LeeDr requested review from a team as code owners August 15, 2022 17:29
@LeeDr LeeDr requested review from joeypoon and parkiino August 15, 2022 17:29
@LeeDr
Copy link
Author

LeeDr commented Aug 15, 2022

@elasticmachine merge upstream

@botelastic botelastic bot added the Team:Fleet Team label for Observability Data Collection Fleet team label Aug 15, 2022
@elasticmachine
Copy link
Contributor

Pinging @elastic/fleet (Team:Fleet)

Copy link
Member

@kpollich kpollich left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fleet changes

const { data, status, statusText } = await axios.delete(`/api/spaces/space/${spaceId}`);

if (status !== 204) {
throw new Error(
log.debug(
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just want to call this out for reviewers. The issue here is that some tests are still unloading an es_archive which contains spaces. This method was failing if trying to delete a space which has already been removed by unloading the es_archive. It appears that this is primarily used as a tearDown step and not any tests.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah my eyebrow raised on this one at first, but I concur. Good call.

Copy link
Member

@pmuellr pmuellr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ResponseOps changes LGTM

@pmuellr
Copy link
Member

pmuellr commented Aug 15, 2022

Though the ResponseOps changes LGTM, I peeked at cleanStandardList() implementation, and we may have a problem with this:

public async cleanStandardList(options?: { space?: string }) {
// add types here
const types = [
'url',
'index-pattern',
'action',
'query',
'alert',

You're not supposed to delete alerting rule SO's (type: alert) directly, as we have task SO's (in the task manager index) that are closely associated with the rule SO's. If you only delete the rule SO, but not the task manager SO, the rule will still attempt to run, as that determination is from the task manager SO, but the rule will fail since there is no rule SO.

While this is likely quite survivable today, since typically nothing bad happens except for excessive logging, we have seen some scenarios in the field of this affecting task manager health (it starts to complain about the failure rate if you delete a lot like this), so it would really be best NOT to delete the rule SO's, just by themselves. It will also cause these "zombie" tasks to delay execution of rules that are currently under test, generally making them run longer, or worse case fail with their own sorts of "timeouts".

I feel like perhaps we can have a way to do alternate delete processing for some of the types, so instead of deleting the rule SO via SO APIs, we'd delete it via the alerting APIs, which delete both SO docs.

@LeeDr
Copy link
Author

LeeDr commented Aug 15, 2022

I feel like perhaps we can have a way to do alternate delete processing for some of the types, so instead of deleting the rule SO via SO APIs, we'd delete it via the alerting APIs, which delete both SO docs.

If rules are defined within a space, does deleting the space take care of the task manager index SOs?

For rules not in a space, it sounds like we would have to use api/alerting/rules/_find and then DELETE api/alerting/rule/ for each id that was found. And it could be paginated... Is there already a cleanup method somewhere in the repo for that?

Copy link
Member

@pheyos pheyos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ML changes LGTM

Copy link
Member

@efegurkan efegurkan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Enterprise Search changes look good.

Copy link
Member

@tsullivan tsullivan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

@parkiino parkiino left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

onboarding lifecycle management changes lgtm

@LeeDr LeeDr enabled auto-merge (squash) August 23, 2022 19:13
@LeeDr LeeDr merged commit f2c20b7 into elastic:main Aug 23, 2022
@kibana-ci
Copy link
Collaborator

💚 Build Succeeded

Metrics [docs]

✅ unchanged

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Aug 23, 2022
…stic#138208)

* replace es_archives/empty_kibana with kibanaServer.savedObjects.cleanStandardList

* [CI] Auto-commit changed files from 'node scripts/precommit_hook.js --ref HEAD~1..HEAD --fix'

* add missing kibanaServer

* add a tearDown

* revert changes that don't pass

* revert fleet_setup, delete spaces in tearDown

* Don't fail on deleting spaces

* revert file for failing test

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
(cherry picked from commit f2c20b7)
@kibanamachine
Copy link
Contributor

💚 All backports created successfully

Status Branch Result
8.4

Note: Successful backport PRs will be merged automatically after passing CI.

Questions ?

Please refer to the Backport tool documentation

kibanamachine added a commit that referenced this pull request Aug 23, 2022
…8208) (#139318)

* replace es_archives/empty_kibana with kibanaServer.savedObjects.cleanStandardList

* [CI] Auto-commit changed files from 'node scripts/precommit_hook.js --ref HEAD~1..HEAD --fix'

* add missing kibanaServer

* add a tearDown

* revert changes that don't pass

* revert fleet_setup, delete spaces in tearDown

* Don't fail on deleting spaces

* revert file for failing test

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
(cherry picked from commit f2c20b7)

Co-authored-by: Lee Drengenberg <lee.drengenberg@elastic.co>
Mpdreamz pushed a commit to Mpdreamz/kibana that referenced this pull request Sep 6, 2022
…stic#138208)

* replace es_archives/empty_kibana with kibanaServer.savedObjects.cleanStandardList

* [CI] Auto-commit changed files from 'node scripts/precommit_hook.js --ref HEAD~1..HEAD --fix'

* add missing kibanaServer

* add a tearDown

* revert changes that don't pass

* revert fleet_setup, delete spaces in tearDown

* Don't fail on deleting spaces

* revert file for failing test

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:prev-minor Backport to (9.0) the previous minor version (i.e. one version back from main) Feature:Functional Testing release_note:skip Skip the PR/issue when compiling release notes Team:Fleet Team label for Observability Data Collection Fleet team test_xpack_functional v8.4.0 v8.5.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.